import os;
import random

def rename():
    count=0;
    path='D:\\dataset\\0'

    filelist=os.listdir(path)#这里是一个文件名列表
    random.shuffle(filelist)#打乱列表的顺序
    for files in filelist:
        oldfile=os.path.join(path,files);
        filename=os.path.splitext(files)[0]
        filetype=os.path.splitext(files)[1]
        newdir=os.path.join(path,str(count)+filetype)
        os.rename(oldfile,newdir);
        count+=1;
rename()
